/*****************************************************************************
 * Copyright (C) Stacy Curl. All rights reserved.                            *
 * ------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the BSD      *
 * style license a copy of which has been included with this distribution in *
 * the LICENSE.txt file.                                                     *
 *****************************************************************************/
package picounit.features.mocking;

import picounit.mocker.Action;
import picounit.mocker.BooleanAction;
import picounit.mocker.BooleanConsequenceCapturer;
import picounit.mocker.BooleanConsequenceMatcher;
import picounit.mocker.ByteAction;
import picounit.mocker.ByteConsequenceCapturer;
import picounit.mocker.ByteConsequenceMatcher;
import picounit.mocker.CharAction;
import picounit.mocker.CharConsequenceCapturer;
import picounit.mocker.CharConsequenceMatcher;
import picounit.mocker.ConsequenceCapturer;
import picounit.mocker.ConsequenceMatcher;
import picounit.mocker.DoubleAction;
import picounit.mocker.DoubleConsequenceCapturer;
import picounit.mocker.DoubleConsequenceMatcher;
import picounit.mocker.FloatAction;
import picounit.mocker.FloatConsequenceCapturer;
import picounit.mocker.FloatConsequenceMatcher;
import picounit.mocker.IntAction;
import picounit.mocker.IntConsequenceCapturer;
import picounit.mocker.IntConsequenceMatcher;
import picounit.mocker.LongAction;
import picounit.mocker.LongConsequenceCapturer;
import picounit.mocker.LongConsequenceMatcher;
import picounit.mocker.OccurencesMatcher;
import picounit.mocker.ShortAction;
import picounit.mocker.ShortConsequenceCapturer;
import picounit.mocker.ShortConsequenceMatcher;
import picounit.mocker.StringAction;
import picounit.mocker.StringConsequenceCapturer;
import picounit.mocker.StringConsequenceMatcher;

@SuppressWarnings("unchecked")
class CombinedConsequenceMatcher extends BaseConsequenceMatcher
	implements BooleanConsequenceMatcher,
	ByteConsequenceMatcher, CharConsequenceMatcher, DoubleConsequenceMatcher,
	FloatConsequenceMatcher, IntConsequenceMatcher, LongConsequenceMatcher,
	ShortConsequenceMatcher, StringConsequenceMatcher, ConsequenceMatcher,
	
	BooleanConsequenceCapturer, ByteConsequenceCapturer, CharConsequenceCapturer,
	DoubleConsequenceCapturer, FloatConsequenceCapturer, IntConsequenceCapturer,
	LongConsequenceCapturer, ShortConsequenceCapturer, StringConsequenceCapturer,
	ConsequenceCapturer {

	public CombinedConsequenceMatcher(ActiveRecordingPlaybackMock activeRecordingPlaybackMock,
		OccurencesMatcher occurencesMatcher, MockInvocationInspector mockInvocationInspector) {
		
		super(activeRecordingPlaybackMock, occurencesMatcher, mockInvocationInspector);
	}

	///////////////////////////////////////////////////////////////////////////////////////////////
	// <Type>ConsequenceMatcher andReturn - single
	///////////////////////////////////////////////////////////////////////////////////////////////

	public OccurencesMatcher andReturn(boolean result) {
		return will(returnValue(new Boolean(result)));
	}

	public OccurencesMatcher andReturn(byte result) {
		return will(returnValue(new Byte(result)));
	}

	public OccurencesMatcher andReturn(char result) {
		return will(returnValue(new Character(result)));
	}

	public OccurencesMatcher andReturn(double result) {
		return will(returnValue(new Double(result)));
	}

	public OccurencesMatcher andReturn(float result) {
		return will(returnValue(new Float(result)));
	}

	public OccurencesMatcher andReturn(int result) {
		return will(returnValue(new Integer(result)));
	}

	public OccurencesMatcher andReturn(long result) {
		return will(returnValue(new Long(result)));
	}

	public OccurencesMatcher andReturn(short result) {
		return will(returnValue(new Short(result)));
	}

	public OccurencesMatcher andReturn(String result) {
		return will(returnValue(result));
	}

	public OccurencesMatcher andReturn(Object result) {
		return isArrayOfResults(result)
			? will(returnConsecutiveValues(result))
			: will(returnValue(result));
	}

	///////////////////////////////////////////////////////////////////////////////////////////////
	// andReturn - multiple
	///////////////////////////////////////////////////////////////////////////////////////////////

	public OccurencesMatcher andReturn(boolean ... results) {
		return will(returnConsecutiveValues(results));
	}
	
	public OccurencesMatcher andReturn(byte ... results) {
		return will(returnConsecutiveValues(results));
	}
	
	public OccurencesMatcher andReturn(char ... results) {
		return will(returnConsecutiveValues(results));
	}
	
	public OccurencesMatcher andReturn(double ... results) {
		return will(returnConsecutiveValues(results));
	}
	
	public OccurencesMatcher andReturn(float ... results) {
		return will(returnConsecutiveValues(results));
	}
	
	public OccurencesMatcher andReturn(int ... results) {
		return will(returnConsecutiveValues(results));
	}
	
	public OccurencesMatcher andReturn(long ... results) {
		return will(returnConsecutiveValues(results));
	}
	
	public OccurencesMatcher andReturn(short ... results) {
		return will(returnConsecutiveValues(results));
	}

	public OccurencesMatcher andReturn(String ... results) {
		return will(returnConsecutiveValues(results));
	}

	public OccurencesMatcher andReturn(Object ... results) {
		return isArrayOfResults(results)
			? will(returnConsecutiveValues(results))
			: will(returnValue(results));
	}

	///////////////////////////////////////////////////////////////////////////////////////////////
	// andPerform
	///////////////////////////////////////////////////////////////////////////////////////////////

	public OccurencesMatcher andPerform(BooleanAction booleanAction) {
		return will(new BooleanActionStub(booleanAction));
	}

	public OccurencesMatcher andPerform(ByteAction byteAction) {
		return will(new ByteActionStub(byteAction));
	}

	public OccurencesMatcher andPerform(CharAction charAction) {
		return will(new CharActionStub(charAction));
	}

	public OccurencesMatcher andPerform(DoubleAction doubleAction) {
		return will(new DoubleActionStub(doubleAction));
	}

	public OccurencesMatcher andPerform(FloatAction floatAction) {
		return will(new FloatActionStub(floatAction));
	}

	public OccurencesMatcher andPerform(IntAction intAction) {
		return will(new IntActionStub(intAction));
	}

	public OccurencesMatcher andPerform(LongAction longAction) {
		return will(new LongActionStub(longAction));
	}

	public OccurencesMatcher andPerform(ShortAction shortAction) {
		return will(new ShortActionStub(shortAction));
	}

	public OccurencesMatcher andPerform(StringAction stringAction) {
		return will(new StringActionStub(stringAction));
	}

	public OccurencesMatcher andPerform(Action action) {
		return will(new ActionStub(action));
	}
	
	///////////////////////////////////////////////////////////////////////////////////////////////
	//  <Type>ConsequenceCapturer methods
	///////////////////////////////////////////////////////////////////////////////////////////////

	public void andReturning(boolean result) {
		andReturn(result);
	}
	
	public void andReturning(byte result) {
		andReturn(result);
	}
	
	public void andReturning(char result) {
		andReturn(result);
	}
	
	public void andReturning(double result) {
		andReturn(result);
	}
	
	public void andReturning(float result) {
		andReturn(result);
	}
	
	public void andReturning(int result) {
		andReturn(result);
	}
	
	public void andReturning(long result) {
		andReturn(result);
	}
	
	public void andReturning(short result) {
		andReturn(result);
	}
	
	public void andReturning(String result) {
		andReturn(result);
	}
	
	public void andReturning(Object result) {
		andReturn(result);
	}

	public void andPerforming(BooleanAction action) {
		andPerform(action);
	}
	
	public void andPerforming(ByteAction action) {
		andPerform(action);
	}
	
	public void andPerforming(CharAction action) {
		andPerform(action);
	}
	
	public void andPerforming(DoubleAction action) {
		andPerform(action);
	}
	
	public void andPerforming(FloatAction action) {
		andPerform(action);
	}
	
	public void andPerforming(IntAction action) {
		andPerform(action);
	}
	
	public void andPerforming(LongAction action) {
		andPerform(action);
	}
	
	public void andPerforming(ShortAction action) {
		andPerform(action);
	}
	
	public void andPerforming(StringAction action) {
		andPerform(action);
	}
	
	public void andPerforming(Action action) {
		andPerform(action);
	}

	public void andRaising(Throwable throwable) {
		andRaise(throwable);
	}
}
